package base64;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author lyy
 * @date 2021/12/20
 */
public class After {

    public static void main(String[] args) throws UnsupportedEncodingException {
        Base64.Encoder encoder = Base64.getEncoder();
        Base64.Decoder decoder = Base64.getDecoder();
        String text = "元旦快乐呀";
        byte[] textBytes = text.getBytes(StandardCharsets.UTF_8);
        String encodeText = encoder.encodeToString(textBytes);
        System.out.println(encodeText);
        String decodeText = new String(decoder.decode(encodeText), StandardCharsets.UTF_8);
        System.out.println(decodeText);
    }

}
